﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_DSJCJ.BLL
{
    /// <summary>
    /// 相片明细 逻辑类
    /// </summary>
    public class AlbumEntry
    {
        /// <summary>
        /// 相片明细DAL
        /// </summary>
        private DAL.AlbumEntry albumEntryDAL = new DAL.AlbumEntry();
        public AlbumEntry()
        {
        }
        /// <summary>
        /// 获取某个相册图片数量
        /// <creator>wangl</creator>
        /// <date>2014-10-13</date>
        /// </summary>
        /// <param name="albumId"></param>
        /// <returns></returns>
        public int GetCountByFAlbumId(int albumId)
        {
            return albumEntryDAL.GetCountByFAlbumId(albumId);
        }

        public List<Model.AlbumEntry> GetListByAlbumId(int albumId)
        {
            DataSet ds = albumEntryDAL.GetListByAlbumId(albumId);
            return DataTableToList(ds.Tables[0]);
        }
      
        /// <summary>
        /// 获取最大显示顺序
        /// <creator>rend</creator>
        /// <date>2012-12-5</date>
        /// </summary>
        /// <param name="docID"></param>
        /// <returns></returns>
        public int GetMaxDispSeq(int albumId)
        {
            return albumEntryDAL.GetMaxDispSeq(albumId);
        }
        /// <summary>
        /// 增加一条数据
        /// <creator>wangl</creator>
        /// <date>2014-10-13</date>
        /// </summary>
        public decimal Add(Model.AlbumEntry model)
        {
            return albumEntryDAL.Add(model);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_DSJCJ.Model.AlbumEntry> DataTableToList(DataTable dt)
        {
            List<ElingOA6_DSJCJ.Model.AlbumEntry> modelList = new List<ElingOA6_DSJCJ.Model.AlbumEntry>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_DSJCJ.Model.AlbumEntry model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = albumEntryDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
    }
}
